#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m; cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		int max_val = -1, max_pos = -1, max_cnt = -1;
		int cnt = 0;
		for (int j = 1; j <= m; j++) {
			int x; cin >> x;
			if (x != 0) cnt++;
			if (x > max_val) {
				max_val = x;
				max_pos = j;
				max_cnt = cnt;
			}
		}
		cout << max_pos << " " << max_cnt - 1 << endl;
	}
	return 0;
}